"use strict";
  
var fs = require("fs"); 

function route(pathname,Antwort) {
		var fileName; 
		var data;
		console.log("About to route a request for " + pathname);
		if(pathname==="/")
			pathname="/index.html";
		var fileName='.'+pathname; 
  
		try {
			data=fs.readFileSync(fileName,"utf-8");
			Antwort.writeHead(200, {"Content-Type": "text/html"}); 
			Antwort.write(data); 
			Antwort.end();
			return true; 
			}catch(err){
			Antwort.writeHead(404, {"Content-Type": "text/html"});
			Antwort.write("<html><body> ");
			Antwort.write( err.message);
			Antwort.write( "<br>");
			Antwort.write("Ich kann nicht "+fileName+" liefern! <br>Es ist ein 404-Fehler."); 
			Antwort.write("</body></html>");
			Antwort.end();
			return 0;
		}  
}

exports.route=route